<template>
  <el-container>
    <el-card class="box-card-wrap">
      <el-main style="padding: 10px !important;">
        <el-row :gutter="20">
          <el-col :span="8" v-for="(item, index) in dataList" :key="index">
            <div class="grid-content bg-purple">
              <el-card class="box-card">
                <div slot="header" class="header">
                  <div class="left">医院：{{ item.deptName }}</div>
                  <div class="right">日期：{{ item.createTime }}</div>
                </div>
                <div class="img-wrap">
                  <el-image style="width: 100%; height: 100%" :preview-src-list="[item.picture]" :fit="contain"
                    :src="item.picture">
                    <div slot="placeholder" class="image-slot">
                      加载中<span class="dot">...</span>
                    </div>
                  </el-image>
                </div>
              </el-card>
            </div>
          </el-col>

        </el-row>
      </el-main>
      <el-footer>
        <div class="block">
          <el-pagination class="pageStyle" background @size-change="handleSizeChange"
            @current-change="handleCurrentChange" :current-page="page.currentPage" :page-sizes="page.pageSizes"
            :page-size="page.pageSize" layout="total,  prev, pager, next, jumper" :total="page.total">
          </el-pagination>
        </div>
      </el-footer>
    </el-card>
  </el-container>
</template>
<script>
import {
  getList,
} from "@/api/infoManagement/diagnosisRecordPrescription";
export default {
  data() {
    return {
      id: '',
      page: {
        pageSize: 8,
        currentPage: 1,
        total: 0,
        pageSizes: [8, 16, 24, 32],
      },
      dataList: []
      // dataList: [
      //   {
      //     name: '第四医院',
      //     id: 1,
      //     time: '2023/3/8',
      //     picture: '/img/chufang1.jpg'
      //   },
      //   {
      //     name: '第九医院',
      //     id: 2,
      //     time: '2023/2/1',
      //     picture: '/img/chufang2.jpeg'
      //   },
      //   {
      //     name: '第四医院',
      //     id: 1,
      //     time: '2023/1/8',
      //     picture: '/img/chufang1.jpg'
      //   },
      //   {
      //     name: '第九医院',
      //     id: 2,
      //     time: '2022/2/1',
      //     picture: '/img/chufang2.jpeg'
      //   },
      //   {
      //     name: '第四医院',
      //     id: 1,
      //     time: '2020/3/8',
      //     picture: '/img/chufang1.jpg'
      //   },
      //   {
      //     name: '第九医院',
      //     id: 2,
      //     time: '2020/2/1',
      //     picture: '/img/chufang2.jpeg'
      //   }
      // ],

    }
  },
  created() {
    this.id = this.$route.query.id
    this.onLoad(this.page)
  },
  methods: {
    handleSizeChange(val) {
      this.page.currentPage = 1
      this.page.pageSize = val
      // console.log(`每页 ${val} 条`)
      this.onLoad(this.page, this.query)
    },
    handleCurrentChange(val) {
      this.page.currentPage = val
      //console.log(`当前页: ${val}`)
      this.onLoad(this.page, this.query)
    },
    onLoad(page, params = {}) {
      this.loading = true;
      getList(page.currentPage, page.pageSize, Object.assign(params, this.query, {
        patientid: this.id
      })).then(res => {
        const data = res.data.data;
        this.page.total = data.total;
        this.dataList = data.records;
        this.loading = false;
        // this.selectionClear();
      });
    }
  }
}
</script>
<style scoped lang="scss">
.img-wrap {
  height: 100%;
  width: 100%;
}

.header {
  position: relative;
  top: 10px;
  height: 40px;

  .left {
    position: absolute;
    left: 5px;
  }

  .right {
    position: absolute;
    right: 5px;
  }
}
</style>
<style>
.box-card-wrap {
  width: 100%;
  height: 100%;
}

.el-row {
  margin-bottom: 20px;

  &:last-child {
    margin-bottom: 0;
  }
}

.el-col {
  border-radius: 4px;
}

.bg-purple-dark {
  background: #99a9bf;
}

.bg-purple {
  background: #d3dce6;
}

.bg-purple-light {
  background: #e5e9f2;
}

.grid-content {
  border-radius: 4px;
  min-height: 36px;
}

.row-bg {
  padding: 10px 0;
  background-color: #f9fafc;
}

.flex {
  display: flex;
}
</style>